package com.uzai.console.web.wechatprivate;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.common.enums.DeviceTypeEnum;
import com.uzai.common.enums.WxqBlacklistTypeEnum;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.device.DeviceQuery;
import com.uzai.console.dto.wechatprivate.wxq.wxgroupmenber.WxGroupMemberBlacklistDto;
import com.uzai.console.dto.wechatprivate.wxq.wxgroupmenber.WxGroupMemberIdDto;
import com.uzai.console.dto.wechatprivate.wxq.wxgroupmenber.WxGroupMemberKickDto;
import com.uzai.console.dto.wechatprivate.wxq.wxgroupmenber.WxGroupMemberQuery;
import com.uzai.console.dto.wechatwork.wxq.wxgroup.AddManagerDto;
import com.uzai.console.dto.wechatwork.wxq.wxgroup.DelManagerDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.wechatprivate.WxGroupMemberService;
import com.uzai.console.vo.base.SelectKeyVo;
import com.uzai.console.vo.device.DeviceInfoVo;
import com.uzai.console.vo.wechatprivate.wxq.wxgroupmember.WxGroupMemberInfoVo;
import com.uzai.console.vo.wechatprivate.wxq.wxgroupmember.WxGroupMemberRelationVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 个人微信群成员成员
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "个人微信群成员", tags = "个人微信|微信群成员")
@ApiSort(5)
@RestController
public class WxGroupMemberController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(WxGroupMemberController.class);

    @Autowired
    private WxGroupMemberService wxGroupMemberMemberService;

    @ApiOperation(value = "查询微信群成员列表", notes = "查询微信群成员列表", response = WxGroupMemberInfoVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/wxGroupMember/findWxGroupMemberList")
    public Object findWxGroupMemberList(@RequestBody WxGroupMemberQuery wxGroupMemberQuery){
        //需要脱敏
        return wxGroupMemberMemberService.findWxGroupMemberList(wxGroupMemberQuery,true);
    }

    @SystemLogType(model = SystemModelEnum.WxGroupMember, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "踢出该群", notes = "踢出该群")
    @ApiOperationSupport(order = 2)
    @PostMapping("/wxGroupMember/kickWxGroupMember")
    public Object kickWxGroupMember(@RequestBody WxGroupMemberKickDto wxGroupMemberKickDto){
        wxGroupMemberMemberService.kickWxGroupMemberByMemberIdList(wxGroupMemberKickDto);
        try {
            Thread.sleep(1000);
        }catch (Exception e){

        }
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxGroupMember, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加好友", notes = "添加好友")
    @ApiOperationSupport(order = 2)
    @PostMapping("/wxGroupMember/addFriend")
    public Object addFriend(@RequestBody WxGroupMemberIdDto wxGroupMemberIdDto){
        wxGroupMemberMemberService.addFriend(wxGroupMemberIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.WxGroupMember, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "加入黑名单", notes = "加入黑名单")
    @ApiOperationSupport(order = 4)
    @PostMapping("/wxGroupMember/addBlacklist")
    public Object addBlacklist(@RequestBody WxGroupMemberBlacklistDto wxGroupMemberBlacklistDto){
        wxGroupMemberMemberService.addBlacklist(wxGroupMemberBlacklistDto);
        try {
            //延迟0.5秒
            Thread.sleep(500);
        }catch (Exception e){

        }
        return true;
    }

    @ApiOperation(value = "查询邀请关系", notes = "查询邀请关系", response = WxGroupMemberRelationVo.class)
    @ApiOperationSupport(order = 5)
    @PostMapping("/wxGroupMember/findInviteRelation")
    public Object findInviteRelation(@RequestBody WxGroupMemberIdDto wxGroupMemberIdDto){
        return wxGroupMemberMemberService.findInviteRelation(wxGroupMemberIdDto);
    }


    @ApiOperation(value = "新增群管理员", notes = "新增群管理员")
    @ApiOperationSupport(order = 6)
    @PostMapping("/wxGroupMember/addManager")
    public Object addManager(@RequestBody AddManagerDto addManagerDto){
        wxGroupMemberMemberService.addManager(addManagerDto);
        return true;
    }


    @ApiOperation(value = "删除群管理员", notes = "删除群管理员")
    @ApiOperationSupport(order = 7)
    @PostMapping("/wxGroupMember/delManager")
    public Object delManager(@RequestBody DelManagerDto delManagerDto){
        wxGroupMemberMemberService.delManager(delManagerDto);
        return true;
    }

}
